package com.mall.service.impl;

import com.mall.mapper.DiscountsMapper;
import com.mall.po.Discounts;
import com.mall.service.DiscountsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhanghui
 * @ClassName DiscountServiceImpl
 * @Description TODO
 * @Date 2021/1/6 22:22
 * @Version 1.0
 **/
@Service
public class DiscountServiceImpl implements DiscountsService {

    @Autowired
    DiscountsMapper discountsMapper;
    /*
     * @Author zhanghui
     * @Description 根据商品名查找活动
     * @Date 2021/1/7 16:33
     * @Param [discountsname]
     * @return com.mall.po.Discounts
     **/
    @Override
    public Discounts findDiscountsByName(String discountsname) {
        return discountsMapper.selectActityBydiscountsname(discountsname);
    }
    /**
     * @Author zhanghui
     * @Description 添加
     * @Date 2021/1/7 16:34
     * @Param [discounts]
     * @return int
     **/

    @Override
    public int addDiscounts(Discounts discounts) {
        return discountsMapper.insertDiscounts(discounts);
    }
/**
 * @Author zhanghui
 * @Description 添加
 * @Date 2021/1/7 16:34
 * @Param [discounts]
 * @return int
 **/
    @Override
    public int updateDiscounts(Discounts discounts) {
        return discountsMapper.updateDiscounts(discounts);
    }
/**
 * @Author zhanghui
 * @Description 删除
 * @Date 2021/1/7 16:35
 * @Param [discountsid]
 * @return int
 **/
    @Override
    public int deleteDiscounts(int discountsid) {
        return discountsMapper.deleteDiscounts(discountsid);
    }
/**
 * @Author zhanghui
 * @Description 批量删除
 * @Date 2021/1/7 16:35
 * @Param [discountsids]
 * @return boolean
 **/
    @Override
    public boolean deleteDiscountList(Integer[] discountsids) {
        if(discountsMapper.deleteDiscountsList(discountsids)){
            return true;
        }
        return false;
    }
/**
 * @Author zhanghui
 * @Description 分页查询
 * @Date 2021/1/7 16:35
 * @Param [page, pagesize]
 * @return java.util.List<com.mall.po.Discounts>
 **/
    @Override
    public List<Discounts> findDiscountsByPage(int page, int pagesize) {
        return discountsMapper.selectDiscountsByPage((page-1)*pagesize,pagesize);
    }
}
